import http from "./http.js";

export const getUser = (data) => {
    let result = http.get(`/user?user=${data.user}&page=${data.page}&size=${data.size}`);
    return result;
}

export const addUser = (data) => {
    let result = http.post(`/adduser`, data);
    return result;
}

export const getParent = (data) => {
    let result = http.get(`/parent?user=${data.user}&page=${data.page}&size=${data.size}`);
    return result;
}

export const addParent = (data) => {
    let result = http.post(`/parent`, data);
    return result;
}
export const updateUser = (data) => {
    let result = http.post('/user', data);
    return result;
}

export const search = (data) => {
    let result = http.post('/search', data);
    return result;
}
export const searchParent = (data) => {
    let result = http.post('/searchParent', data);
    return result
}

export const exportFile = async (data) => {
    let result = await http.get(`/export?user=${data}`, {
        responseType: 'blob'
    });
    console.log(result);
    const url = window.URL.createObjectURL(new Blob([result.data]));
    const link = document.createElement('a');
    link.href = url;
    link.setAttribute('download', '补充信息汇总表.xlsx'); // 指定下载的文件名
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
}